<template>
  <div class="app-container" id="home">
    <mt-search
      :v-model="searchWord"
      :cancel-text="cancelText"
      :placeholder="placeholder">
    </mt-search>
    <div class="goods">
      <ul class="good-list">
        <li v-for="(item, index) in goods" :key="index" >
          <img :src="item.picurl" alt="">
          <div class="text">
            <div class="name">{{item.name}}</div>
            <div class="price">￥{{item.price}}</div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { getGoods } from '@/API/good'
export default {
  name: 'home',
  data() {
    return {
      searchWord: '',
      cancelText: '取消',
      placeholder: '输入商品、店铺',
      goods: []
    }
  },
  mounted() {
    this.getGoods()
  },
  methods: {
    getGoods() {
      this.goods = require('./data.js')
      getGoods().then((response)=>{
        this.goods = response.data.result
      })
    }
  }
}
</script>

<style lang="less" scoped>
.app-container {
  display: flex;
  flex-direction: column;
  .goods {
    flex: 1;
    ul {
      height: 100%;
      overflow: auto;
    }
  }
}
.mint-search {
  height: auto;
}
ul.good-list {
  li {
    display: flex;
    padding: 5px 0;
    img {
      width: 100px;
      height: 100px;
    }
    .text {
      padding: 5px;
      .name {
        font-size: 18px;
      }
      .price {
        color: #efb329;
        margin-top: 50px;
      }
    }
  }
}
</style>
